//
//  AbstractViewController.m
//  yigou
//
//  Created by wangdianlei on 2017/1/4.
//  Copyright © 2017年 hanyiwang. All rights reserved.
//

#import "AbstractViewController.h"
#import "RefreshComponent.h"

@interface AbstractViewController ()

@property (strong, nonatomic) UILabel *nodata;

@end

@implementation AbstractViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.nodata = [[UILabel alloc] initWithFrame:CGRectMake(ScreenWidth / 2 - 100, ScreenHeight / 2 - 50 - 64, 200, 100)];
    self.nodata.font = [FontTool fontWithSize:20];
    self.nodata.textAlignment = NSTextAlignmentCenter;
    self.nodata.textColor = [UIColor blackColor];
    self.nodata.text = @"暂无数据";
    self.nodata.hidden = YES;
    [self.view addSubview:self.nodata];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
//    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
//        self.navigationController.interactivePopGestureRecognizer.delegate = nil;
//    }
    [self.view bringSubviewToFront:self.nodata];
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    [MobStatHelper pageAppear:NSStringFromClass([self class])];
    //NSLog(@"appear class name>> %@",NSStringFromClass([self class]));
}

- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
    [MobStatHelper pageDisappear:NSStringFromClass([self class])];
    //NSLog(@"disappear class name>> %@",NSStringFromClass([self class]));
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)showNoData {
    self.nodata.hidden = NO;
}

- (void)hideNoData {
    self.nodata.hidden = YES;
}

- (void)addRefreshHeader:(UITableView *)tableview {
    //    [tableview addGifHeaderWithRefreshingTarget:self refreshingAction:@selector(refresh)];
    //    tableview.header.updatedTimeHidden = YES;
    //    [tableview.gifHeader setImages:[RefreshComponent sharedRefreshComponent].idleImages forState:MJRefreshHeaderStateIdle];
    //    [tableview.gifHeader setImages:[RefreshComponent sharedRefreshComponent].refreshImages forState:MJRefreshHeaderStatePulling];
    //    [tableview.gifHeader setImages:[RefreshComponent sharedRefreshComponent].refreshImages forState:MJRefreshHeaderStateRefreshing];
//    MJRefreshGifHeader *headerGif = [MJRefreshGifHeader headerWithRefreshingTarget:self refreshingAction:@selector(refresh)];
//    headerGif.lastUpdatedTimeLabel.hidden = YES;
//    [headerGif setImages:[RefreshComponent sharedRefreshComponent].idleImages forState:MJRefreshStateIdle];
//    [headerGif setImages:[RefreshComponent sharedRefreshComponent].refreshImages forState:MJRefreshStatePulling];
//    [headerGif setImages:[RefreshComponent sharedRefreshComponent].refreshImages forState:MJRefreshStateRefreshing];
//    tableview.header = headerGif;
    
    tableview.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(refresh)];
}

- (void)addLoadMoreFooter:(UITableView *)tableview {
    //    [tableview addLegendFooterWithRefreshingTarget:self refreshingAction:@selector(loadMore)];
    //    // 设置文字
    //    [tableview.footer setTitle:@"上拉获取更多数据" forState:MJRefreshFooterStateIdle];
    //    //[tableview.footer setTitle:@"Loading more ..." forState:MJRefreshFooterStateRefreshing];
    //    //[tableview.footer setTitle:@"No more data" forState:MJRefreshFooterStateNoMoreData];
    
//    MJRefreshAutoStateFooter *footer = [MJRefreshAutoStateFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMore)];
//    [footer setTitle:@"上拉获取更多数据" forState:MJRefreshStateIdle];
//    tableview.footer = footer;
    
    MJRefreshAutoStateFooter *footer = [MJRefreshAutoStateFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMore)];
    //[footer setTitle:@"上拉获取更多数据" forState:MJRefreshStateIdle];
    [footer setTitle:@"" forState:MJRefreshStateIdle];
    tableview.mj_footer = footer;
}

- (void)refresh {
    
}

- (void)loadMore {
    
}

@end
